%% To display line cut of GID data along horizontal line
close all
GID_Qxy_File={
%     'sph01_scan78_hline.txt';  % SPM on KCl at neutral pH
%     'sph02_scan115_hline.txt'; % SPM on KCl/FeCl3 at pH 5.0
%     'sph01_scan342_hline.txt'; % SPM on KCl/FeCl3 at pH 4.0 
%     'sph01_scan272_hline.txt'; % SPM on KCl/FeCl3 at pH 7.1
%     'sph02_scan238_hline.txt'; % SPM on KCl/FeCl3 at pH 3.0
%     'sph02_scan50_hline.txt';  % SPM on KCl/FeCl3 at pH 2.0
    'sph01_scan78_hline.txt';  % SPM on KCl at neutral pH
    'sph01_scan362_hline.txt'; % SPM on KCl/FeCl3 at pH 4.0
    'sph01_scan278_hline.txt'; % SPM on KCl/FeCl3 at pH 7.1
    }

MARKER={'o','s','v','^'}
COLOR={'k','b','r',[0 0.4 0],'k'}
figure
subplot(1,2,1);
hold on
xfit=(1.1:0.001:1.7);
start=[1,... % height
       0.1,... % Width
       1.5,... % position
       0,... % slope
       0]; % constant
   LB=[0,0.001,1.4,0,0]
   UB=[10,1,1.6,10,0.5];
   Param={}
for k=1:length(GID_Qxy_File)
    
    
    data=dlmread(GID_Qxy_File{k});
    temp=data(:,1);
    xdata=data(temp<1.8 & temp>1,1);
    ydata=data(temp<1.8 & temp>1,2);
    ydata_err=data(temp<1.8 & temp>1,3);
    
    Param{k}=optim_fitLorentzian1peak(start,xdata,ydata,ydata_err,LB,UB);
    yfit=fitLorentzian1peak(Param{k},xfit);
    plot(xfit,yfit,'-','LineWidth',3,'Color',COLOR{k});
    H=ploterr(xdata,ydata,[],ydata_err,MARKER{k});
    set(H,'linewidth',3,'Color',COLOR{k},'MarkerSize',12,'MarkerFaceColor','w');
end
hold off
set(gca,'LineWidth',3,'box','on');
set(gca,'FontSize',30);
set(gca,'xlim',[0.95,1.85],'xtick',[1.1:0.2:1.7]);
set(gca,'ylim',[0.2 1.75],'ytick',[0.5:0.5:1.5]);
axis square